import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunkMiddleware from 'shared/middleware/thunkMiddleware';
import errorMiddleware from 'shared/middleware/errorMiddleware';
import rootReducer from '../reducer';

const configureStore =  (initialState = {}) => {
  const middlewareList = [thunkMiddleware, errorMiddleware];
  const middleware = composeWithDevTools(applyMiddleware(...middlewareList));

  const store = middleware(createStore)(rootReducer, initialState);

  return store;
};

const store = configureStore();
export default store;